// shopMallPackage/pages/score/myScore/myScore.js
import { getMyWallet } from "../../../../service/onetoone_service"
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    scoreData: {},
    withDrawMoney: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (app.globalData.cashMinMoney) {
      this.setData({
        withDrawMoney: app.globalData.cashMinMoney,
      })
    }

  },



  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.myWalletInfo();
  },

  //获取我的积分数据:
  myWalletInfo() {
    wx.showLoading();
    getMyWallet().then(res => {
      console.log("JJLog:钱包数据===:" + JSON.stringify(res));
      wx.hideLoading();
      if (res.code == 200) {
        this.setData({
          scoreData: res.data
        })
      }
    }).catch(err => {
      wx.hideLoading();
      wx.showToast({
        title: err || "查询失败",
        icon: "none"
      })
      console.error("JJLog:getMyWallet", err);
    })
  },

  // 跳转到提现页面
  pushToWithdraw() {
    if (this.data.scoreData.restMoney < this.data.withDrawMoney) {
      wx.showToast({
        title: '您的积分余额小于最小可提现额度',
        icon: "none"
      })
      return;
    }
    wx.navigateTo({
      url: '/shopMallPackage/pages/score/scoreWithdraw/scoreWithdraw',
    })
  },
  // 跳转到
  pushToIncomeList() {
    wx.navigateTo({
      url: '/storePackage/pages/calculusDetail/calculusDetail',
    })
  },







})